$(function () {
    
    $('form').on('submit', async e => {
        e.preventDefault()
        console.log($('form').serialize());
        
        const res = await $.ajax({
            url: '/users/login',
            data: $('form').serialize(),
            method: 'post'
        })
        console.log(res);
        if (res.code !== 1) {
            $('form .error').text(res.message).show()
            return
        }
        window.sessionStorage.setItem('id',res.info.id)
        window.location.href = '/pages/index'
    })
})